package com.ddedu.controller;

import com.ddedu.common.JsonResult;
import com.ddedu.entity.User;
import com.ddedu.entity.Week;
import com.ddedu.service.WeekService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author lenovo on 2020/9/1 21:24
 */
@Controller
@RequestMapping("/week")
public class WeekController {
    @Autowired
    private WeekService weekService;

    @RequestMapping("add.do")
    @ResponseBody
    public JsonResult add(String title, String content, HttpSession session) {
        User user = (User)session.getAttribute("loginUser");

        Week week = new Week();
        week.setTitle(title);
        week.setContent(content);
        week.setStatus(1);
        week.setU_no(user.getNo());
        System.out.println(week);
        weekService.add(week);

        return new JsonResult(1,"添加成功！");
    }
}
